package Controleur;

import java.util.ArrayList;
import minipad.UpdateViewReceiver;

/**
 * @author David Phung, Michel Fraser
 */
public class ReplayMgr {
    private ArrayList<ReplayObj> list;
    private UpdateViewReceiver uvr;

    public void add(ReplayInterface rep,Character c){
        list.add(new ReplayObj(rep, c));
    }

    public ReplayMgr(UpdateViewReceiver u) {
        list = new ArrayList<ReplayObj>();
        uvr=u;
    }

    public boolean isListEmpty(){
        return list.isEmpty();
    }

    public void clearList(){
        list.clear();
    }

    public void play(){
        for(ReplayObj r: list) {

            if (r.rep instanceof InsererCmd){
                uvr.updateLastChar(r.c);
                r.rep.execute();
            }
        }
    }

}

class ReplayObj {
    Character c;
    ReplayInterface rep;

    public ReplayObj(ReplayInterface r,Character ch){
        c=ch;
        rep=r;
    }
}
